import {UserActions} from './user';

const initialState = {
  count: 0,
  current: 0,
  total: 0,
  results: [],
};

export const MenuParams = {
  vendor_manage: 'vendor_manage',
  dentist_manage: 'dentist_manage',
  charge_manage: 'charge_manage',
  order_manage: 'order_manage',
  praise_manage: 'praise_manage',
  operate_manage: 'operate_manage',
  master_manage: 'master_manage',
};

export const ParamNames = {
  vendor_manage: '供应商管理',
  dentist_manage: '诊所管理',
  charge_manage: '充值管理',
  order_manage: '订单管理',
  praise_manage: '评价管理',
  operate_manage: '运营管理',
  master_manage: '系统设置',
};

export const RoleListActions = {
  ROLE_LIST_UPDATE: 'role_list_update',
};

export function updateRoleList(payload) {
  return {
    type: RoleListActions.ROLE_LIST_UPDATE,
    payload,
  };
}

export default function roleList(state = initialState, action) {
  switch (action.type) {
    case RoleListActions.ROLE_LIST_UPDATE:
      return {...state, ...action.payload};
    case UserActions.USER_SIGN_OUT:
      return {
        count: 0,
        current: 0,
        total: 0,
        results: [],
      };
    default:
      return state;
  }
}
